package com.geepi.soundcloud.controller;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class Test {
	public static void main(String[] args) {
		String updateTime = "2017-05-08 14:03:07";
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		try {
			Date date = sdf.parse(updateTime);
			if (isToday(date)) {
				System.out.println("is today...");
			} else {
				System.out.println("isn't today...");
			}
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		// String highAttrStr = "{\"1031\":[2]}";
		//
		// try {
		// ObjectMapper mapper = new ObjectMapper();
		// Map<String, Object> map = mapper.readValue(highAttrStr, Map.class);
		// Iterator<Entry<String, Object>> it = map.entrySet().iterator();
		// while (it.hasNext()) {
		// Entry<String, Object> entry = it.next();
		// System.out.println("key= " + entry.getKey() + " and value= " +
		// entry.getValue());
		// }
		// } catch (JsonParseException e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// } catch (JsonMappingException e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// } catch (IOException e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// }

		System.out.println("Hello World!");

		/* 高级属性评分因子默认值,scroe*weight */
		/* 网络/供电 */
		// String[] baseScoreStrs = { "80&0.01", "80&0.01" };
		// for (int i = 0; i < baseScoreStrs.length; i++) {
		// String[] scoreStrs = baseScoreStrs[i].split("&");
		// Double score = Double.parseDouble(scoreStrs[0]) *
		// Double.parseDouble(scoreStrs[1]);
		// System.out.println("score:" + score);
		// }

	}
	
    public static boolean isToday(Date date) { 
        Calendar c1 = Calendar.getInstance();              
        c1.setTime(date);                                 
        int year1 = c1.get(Calendar.YEAR);
            int month1 = c1.get(Calendar.MONTH)+1;
            int day1 = c1.get(Calendar.DAY_OF_MONTH);     
            Calendar c2 = Calendar.getInstance();    
            c2.setTime(new Date());      
            int year2 = c2.get(Calendar.YEAR);
            int month2 = c2.get(Calendar.MONTH)+1;
            int day2 = c2.get(Calendar.DAY_OF_MONTH);   
            if(year1 == year2 && month1 == month2 && day1 == day2){
            return true;
            }
        return false;                               
    }
}